<?php
namespace App\Jobs;
use App\Services\Promotion\CouponService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;

/**
 * 客户优惠券发放队列
 *
 * @author WangBin
 * @date
 */
class CouponAssignJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable;

    private $logId;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(int $logId)
    {
        $this->logId = $logId;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Log::debug("[队列][发放优惠券] 开始执行...");
        CouponService::getInstance()->assign($this->logId);
        Log::debug("[队列][发放优惠券] 执行结束...");
    }
}
